# 双指针法
class Solution(object):
    def moveZeroes(self, nums):
        """
        :type nums: List[int]
        :rtype: None Do not return anything, modify nums in-place instead.
        """
        write = 0
        for read in range(len(nums)):
            if read != 0:
                write += 1
                # write是滞后,0的位置的索引
                nums[write] = nums[read]
        for i in range(write,len(nums)):
            nums[i] = 0


    def move_zero(self,nums):
        wirte = 0 
        for read in range(len(nums)):
            if nums[read] != 0:
                nums[wirte],nums[read] = nums[read], nums[wirte]
                wirte += 1
        return nums



a = [0,1,0,3,12]
print(Solution().move_zero(a))